/*
 * @Author: Mr.Cong Wei
 * @Date: 2022-07-26 20:33:44
 * @LastEditTime: 2022-07-26 20:40:37
 */
const Axios = require('axios')
const url = require('url')
const { baseURL } = require('./setting')

const urlParsed = url.parse(baseURL);

// 代理服务器
const proxyHost = "t.16yun.cn";
const proxyPort = "36600";

// 生成一个随机 proxy tunnel
let seed = 1;
function random() {
    var x = Math.sin(seed++) * 10000;
    return x - Math.floor(x);
}
const tunnel = random() * 100;

const axios = Axios.create({
    timeout: 0,
    host: proxyHost,
    port: proxyPort,
    baseURL: baseURL,
    headers: {
        "Host": urlParsed.hostname,
        "Proxy-Tunnel": tunnel,
        "Proxy-Authorization": "Basic "
    }
})

module.exports = axios